<template>
  <div class="app-container">
    <Ht-search-form
      v-show="showSearch"
      :advOptions="[]"
      :dictMap="dictMapAsync"
      :formOptions="formOptions"
      :outputQueryParams="queryParams"
      :queryParams="queryParams"
      :labelWidth="90"
    ></Ht-search-form>

    <!--    <div class="page-label-block">-->
    <!--      <span class="color-block">|</span>-->
    <!--      <span class="page-label-name">-->
    <!--      租户管理-->
    <!--      </span>-->
    <!--    </div>-->

    <ht-table
      ref="dataTable"
      :dictMap="dictMap"
      :multi-select="false"
      :opButtonList="opButtonList"
      :queryParams="queryParams"
      :reqConfig="regConfig"
      :showSerialNumber="false"
      :tableBindColumns="tableBindColumns"
    >
      <template v-slot:operate>
        <el-table-column align="left" fixed="right" label="操作" width="50">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    handleAction('detail', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>

    <!-- 添加或修改弹出框 -->
    <el-dialog
      v-if="open"
      :close-on-click-modal="false"
      :title="title"
      center
      :visible.sync="open"
      append-to-body
      width="1024px"
    >
      <el-form ref="detailForm" :disabled="true" :model="detailForm" label-width="140px">
        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>基本信息</span>
          </div>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="交易流水号" prop="id">
                <el-input v-model="detailForm.id" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="系统编号" prop="sysCode">
                <el-select v-model="detailForm.sysCode" placeholder="系统编号" style="width: 100%">
                  <el-option
                    v-for="dict in dictMap.SYS_CODE_310_312"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="报文标识号" prop="pkgid">
                <el-input v-model="detailForm.pkgid" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="内部机构号" prop="brno">
                <el-select v-model="detailForm.brno" placeholder="内部机构号" style="width: 100%">
                  <el-option
                    v-for="dict in dictMap['Cnaps2Dict.CP2_BRNO']"
                    :key="dict.value"
                    :label="`${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="工作日期" prop="workdate">
                <el-date-picker v-model="detailForm.workdate" style="width: 100%" type="date" value-format="yyyyMMdd" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="CPG日期" prop="vdate">
                <el-date-picker v-model="detailForm.vdate" style="width: 100%" type="date" value-format="yyyyMMdd" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="发起参与机构" prop="indirectSender">
                <el-input v-model="detailForm.indirectSender" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="发起参与机构名称" prop="indirectSenderName">
                <el-input v-model="detailForm.indirectSenderName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="应答参与机构" prop="indirectRcver">
                <el-input v-model="detailForm.indirectRcver" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="应答参与机构名称" prop="indirectRcverName">
                <el-input v-model="detailForm.indirectRcverName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原报文类型" prop="oriPkgtype">
                <el-select v-model="detailForm.oriPkgtype" placeholder="原报文类型" style="width: 100%">
                  <el-option
                    v-for="dict in dictMap.PKG_TYPE_316"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="通讯状态" prop="status">
                <el-select v-model="detailForm.status" placeholder="通讯状态" style="width: 100%">
                  <el-option
                    v-for="dict in dictMap.PKG_STATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原交易流水号" prop="oriId">
                <el-input v-model="detailForm.oriId" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="原报文标识号" prop="oriPkgid">
                <el-input v-model="detailForm.oriPkgid" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="录入操作员" prop="mdTlrno">
                <el-input v-model="detailForm.mdTlrno" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="录入时间" prop="mdTime">
                <el-date-picker
                  v-model="detailForm.mdTime"
                  style="width: 100%"
                  type="datetime"
                  value-format="yyyyMMddHHmmss"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>NPC处理信息</span>
          </div>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="NPC处理状态日期" prop="stDate">
                <el-date-picker v-model="detailForm.stDate" style="width: 100%" type="date" value-format="yyyyMMdd" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="NPC处理状态" prop="npcProcStatus">
                <el-select v-model="detailForm.npcProcStatus" placeholder="NPC处理状态" style="width: 100%">
                  <el-option
                    v-for="dict in dictMap.PROCESSSTATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="NPC处理码" prop="npcProcCode">
                <el-input v-model="detailForm.npcProcCode" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="NPC轧差场次" prop="chkRound">
                <el-input v-model="detailForm.chkRound" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="NPC接收时间" prop="npcRcvTime">
                <el-date-picker
                  v-model="detailForm.npcRcvTime"
                  style="width: 100%"
                  type="datetime"
                  value-format="yyyyMMddHHmmss"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="NPC转发时间" prop="npcTranTime">
                <el-date-picker
                  v-model="detailForm.npcTranTime"
                  style="width: 100%"
                  type="datetime"
                  value-format="yyyyMMddHHmmss"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="NPC轧差日期" prop="chkDate">
                <el-date-picker v-model="detailForm.chkDate" style="width: 100%" type="date" value-format="yyyyMMdd" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="通知状态标志" prop="noteStatFlag">
                <el-select v-model="detailForm.noteStatFlag" placeholder="通知状态标志" style="width: 100%">
                  <el-option
                    v-for="dict in dictMap.NOTE_STAT_FLAG"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="24">
              <el-form-item label="NPC拒绝信息" prop="rejectInfo">
                <el-input v-model="detailForm.rejectInfo" type="textarea" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原申请报文的拒绝状态" prop="rejectStatus">
                <el-select v-model="detailForm.rejectStatus" placeholder="原申请报文的拒绝状态" style="width: 100%">
                  <el-option
                    v-for="dict in dictMap.PROCESSSTATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="原申请报文的拒绝码" prop="rejectCode">
                <el-input v-model="detailForm.rejectCode" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="申请发送时间" prop="sndTime">
                <el-date-picker
                  v-model="detailForm.sndTime"
                  style="width: 100%"
                  type="datetime"
                  value-format="yyyyMMddHHmmss"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="应答接收时间" prop="rcvTime">
                <el-date-picker
                  v-model="detailForm.rcvTime"
                  style="width: 100%"
                  type="datetime"
                  value-format="yyyyMMddHHmmss"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
      </el-form>

      <div slot="footer" align="center" class="dialog-footer">
        <el-button type="primary" @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { apiUrlConfigQuery } from "@/api/cnaps/ccms/316";
import { listPageMixin } from "@/libs/listPageMixin";
import { mapGetters } from "vuex";
export default {
  name: "BusinessStatQryQuery",
  mixins: [listPageMixin],
  components: {},

  computed: {
    ...mapGetters(["globalBusData"]),
  },
  created() {
    this.$set(this.queryParams, "brno", this.globalBusData.brno);
  },
  watch: {
    globalBusData: {
      handler(val) {
        this.$set(this.queryParams, "brno", val.brno);
      },
      deep: true,
      immediate: true,
    },
  },
  data() {
    return {
      // 查询参数
      queryParams: {
        id2: undefined,
        brno: undefined,
        pkgid: undefined,
        cpgdate: undefined,
        cpgdate2: undefined,
        workdate: undefined,
        workdate2: undefined,
        indirectSender: undefined,
        oriPkgid: undefined,
        oriPkgtype: undefined,
      },

      // 搜索
      formOptions: [],
      //
      searchFormDictList: [
        "PKG_TYPE_316",
        "SYS_CODE_310_312",
        "TXN_SOURCE",
        "PKG_STATUS",
        "PROCESSSTATUS",
        "NOTE_STAT_FLAG",
        "Cnaps2Dict.CP2_BRNO",
      ],
      // 列信息
      regConfig: apiUrlConfigQuery,

      tableBindColumns: [
        {
          prop: "brno",
          align: "center",
          label: "内部机构号",
          dictCode: "Cnaps2Dict.CP2_BRNO",
          sortable: false,
        },
        {
          prop: "sysCode",
          align: "center",
          label: "系统编号",
          dictCode: "SYS_CODE_310_312",
          width: "200",
        },
        {
          prop: "id",
          align: "center",
          label: "交易流水号",
          width: "200",
        },
        {
          prop: "vdate",
          align: "center",
          label: "CPG日期",
          type: "date",
        },
        {
          prop: "workdate",
          align: "center",
          label: "工作日期",
          type: "date",
        },
        {
          prop: "indirectSender",
          align: "center",
          label: "发起参与机构号",
          width: "150",
        },
        {
          prop: "indirectRcver",
          align: "center",
          label: "接收参与机构",
          width: "150",
        },
        {
          prop: "source",
          align: "center",
          label: "来源",
          dictCode: "TXN_SOURCE",
        },
        {
          prop: "oriPkgid",
          align: "center",
          label: "原报文标识号",
          width: "150",
        },
        {
          prop: "oriPkgtype",
          align: "center",
          label: "原报文类型",
          dictCode: "PKG_TYPE_316",
          width: "300",
        },
      ],
      dictMapAsync: {},
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数

      totalRecord: 0,
      totalPage: 0,
      needCount: 0,

      rules: {},
    };
  },
  mounted() {
    const formOptions = [
      // 普通搜索

      {
        type: "input",
        prop: "id2",
        defaultAttr: {
          size: "small",
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },
      {
        type: "search-dept-tree",
        prop: "brno",
        defaultAttr: {
          radio: false,
          linkParentChoose: false,
          label: "分行选择",
          placeholder: "请选择分行",
          disabled: true,
        },
      },
      {
        type: "input",
        prop: "pkgid",
        defaultAttr: {
          size: "small",
          label: "报文标识号",
          placeholder: "请输入报文标识号",
        },
      },
      {
        type: "input",
        prop: "indirectSender",
        defaultAttr: {
          size: "small",
          label: "发起参与机构号",
          placeholder: "请输入发起参与机构号",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "cpgdate",
          endTimeName: "cpgdate2",
        },
        defaultAttr: {
          size: "small",
          label: "CPG日期",
          placeholder: ["请输入CPG开始日期", "请输入CPG结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate",
          endTimeName: "workdate2",
        },
        defaultAttr: {
          size: "small",
          label: "工作日期",
          placeholder: ["请输入工作开始日期", "请输入工作结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

      {
        type: "input",
        prop: "oriPkgid",
        defaultAttr: {
          size: "small",
          label: "原报文标识号",
          placeholder: "请输入原报文标识号",
        },
      },

      {
        type: "dict",
        dict: "PKG_TYPE_316",
        prop: "oriPkgtype",
        defaultAttr: {
          size: "small",
          label: "原报文类型",
          placeholder: "请输入原报文类型",
        },
      },
    ];
    this.formOptions = formOptions;
    this.dictMapAsync = this.getDictMap();
  },
  methods: {
    /***
     * 按钮操作汇总
     */
    /***
     * 按钮操作汇总
     */
    handleAction(type, row = {}) {
      switch (type) {
        case "detail":
          this.handleDetail(row);
          break;
      }
    },

    // 关闭按钮
    cancel() {
      this.open = false;
    },

    /** 详情按钮操作 */
    handleDetail(row) {
      this.title = "业务状态查询申请查询明细";
      console.log(row);
      this.detailForm = row;
      this.open = true;
    },
  },
};
</script>
